<?php
namespace App\Http\Controllers\Xcx;

use App\Service\Xcx\YqhService;
use Illuminate\Http\Request;

class YqhController extends BaseController
{
    //邀请函

    //详情
    public function one(Request $request)
    {
        $id = $request->post('id', 0);
        $res = YqhService::one($id);
        if ($res['code'] < 0) {
            return $this->toJson(-2, $res['msg']);
        }
        return $this->toJson(0, '', $res['data']);
    }

    //流程列表
    public function flowList(Request $request)
    {
        $id = $request->post('id', 0);
        $pages['start'] = $request->post('page', 1);
        $pages['limit'] = $request->post('size', 10);
        $res = YqhService::flowList($id, $pages);
        if ($res['code'] < 0) {
            return $this->toJson(-2, '没有数据');
        }
        return $this->toJson(0, '', $res['data'], $res['total']);
    }

    //预约
    public function apply(Request $request)
    {
        $id = $request->post('yqh_id', 0);
        $uid = $request->post('uid', 0);
        $res = YqhService::apply($id, $uid);
        if ($res['code'] < 0) {
            return $this->toJson(-2, $res['msg']);
        }
        return $this->toJson();
    }
}